package com.fengpb.friday.conductor.client.controller;

import com.alibaba.nacos.api.annotation.NacosInjected;
import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.api.naming.NamingService;
import com.alibaba.nacos.api.naming.pojo.Instance;
import org.springframework.web.bind.annotation.*;

import java.util.Collections;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("test")
public class TestController {

    @NacosInjected
    private NamingService namingService;

    @GetMapping(value = "/get/{serviceName}")
    public List<Instance> get(@PathVariable String serviceName) throws NacosException {
        return namingService.getAllInstances(serviceName);
    }

    @GetMapping("test")
    public Map<String, String> test() {
        return Collections.singletonMap("name", "chris");
    }
}
